﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IntelligentDecisioning.SharePoint.Definition;
using Microsoft.SharePoint;
using IntelligentDecisioning.SharePoint.BusinessEntities;
using Microsoft.Practices.SPG.Common.ListRepository;
using IntelligentDecisioning.SharePoint.Helpers;
using IntelligentDecisioning.SharePoint.Definition.Lists;

namespace IntelligentDecisioning.SharePoint.Definitions
{
    public class DemonstrationDocumentLibraryList : SharePointDocumentLibrary
    {
       
        public DemonstrationDocumentLibraryList()
            : base("Demo Document Library")
        {

        }


        public List<DemonstrationDocumentLibraryEntity> GetDocuments(SPWeb targetWeb)
        {
            ListItemFieldMapper<DemonstrationDocumentLibraryEntity> entityFieldMapper = new ListItemFieldMapper<DemonstrationDocumentLibraryEntity>();
            entityFieldMapper.FieldMappings = new SharePointDocumentLibrary().GetFieldMappings();

            List<DemonstrationDocumentLibraryEntity> entityList = new List<DemonstrationDocumentLibraryEntity>();
            IDListHelper listHelper = new IDListHelper(targetWeb.Site, targetWeb);
            SPList list = listHelper.GetList(Name);

            foreach (SPListItem item in list.Items)
            {
                DemonstrationDocumentLibraryEntity demonstrationDocumentLibraryEntity = entityFieldMapper.CreateEntity(item);
                entityList.Add(demonstrationDocumentLibraryEntity);
            }

            return entityList;
        }
    }
}
